<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/6/23
 * Time: 9:31
 */

namespace app\common\model\media;


use app\common\model\TimeModel;

class Comment extends TimeModel
{

    //发布评论的人
    public function user(){
        return $this->belongsTo('app\common\model\user\WxUsers','from_uid','id');
    }
//子评论
    public function childs()
    {
        return $this->hasMany('app\common\model\media\Comment','pid','id');
    }

    //帖子
    public function topic()
    {
        return $this->belongsTo('app\common\model\user\Topic','topic_id','id');
    }
    public static function onAfterInsert($data){

        //$self = new static();
        $article = self::withoutGlobalScope()->find($data->id);

        $article->withoutGlobalScope()->where('id',$data->id)->save(['app_id'=>self::get_appId()]);

    }
}